<script>
export default {
    name: "GoodsList",
    methods:{
        fn(){

        }
    },
    beforeRouteLeave(to,from,next){
        console.log("beforeRouteLeave->离开前执行->to",to);// 去哪个路由
        console.log("beforeRouteLeave->离开前执行->from",from);// 当前路由
        if(window.confirm("您确定要离开该表单吗？")){
            next();// 离开
        }
    }
}
</script>

<template>
    <div>
        <h3>商品列表界面</h3>
        <form>
            <p>商品的名称：<input type="text"></p>
            <p>商品的价格：<input type="text"></p>
            <button @click.prevent="fn">提交</button>
        </form>
    </div>

</template>

<style scoped>

</style>